#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int num[1000000];
int ans[1000000];
int head[1000000],tail[1000000];
bool err[1000000]={0};
int main()
{
//	freopen("candy.in","r",stdin);
//	freopen("candy.out","w",stdout);
    long long n,x;
    long long k=0;
    scanf("%llf",&n);
    for(int i=0;i<n;i++){
    	cin>>num[i];
		if(i==0){
			x=num[i];
			head[k]=i;
		} 
		if(x!=num[i]){
			k++;
			head[k]=i;
			tail[k]=i-1;
		}			
	}
	int j=0;
	bool f=1;
	while(f){
		f=0;
		for(int j=0;j<=k;j++){
		    if(err[j]==1) continue;
		    cout<<head[j]<<" ";
		    head[j]++;
		    if(head[j]>tail[j]){
			    err[j]=1;
		    }
	    }
	    cout<<endl;
	}
    return 0;
}
